/**
 * 装饰器
 */

class Circle {
    draw() {
        return 'draw a circle'
    }
}

function Decorator(target) {
    const res = target.prototype.draw.call(this, arguments)
    target.draw = function () {
        console.log('decorator: ', res)
    }

    target.setBorderRed = function () {
        console.log('set border red')
    }

    return target
}

function test() {
    const c1 = new Circle()
    c1.draw()

    const c2 = new Decorator(Circle)
    c2.draw()
    c2.setBorderRed()
}

console.log('----------------装饰器模式-------------------')
test()